package cn.ibizlab.util.adapter.service;

import cn.ibizlab.util.adapter.util.helper.DataEntityUtil;
import cn.ibizlab.util.security.SpringContextHolder;
import net.ibizsys.central.ISystemRuntime;
import net.ibizsys.central.dataentity.IDataEntityRuntime;
import net.ibizsys.central.service.ISysServiceAPIRuntime;
import net.ibizsys.model.dataentity.action.IPSDEAction;
import net.ibizsys.central.dataentity.service.IDEServiceAPIRuntime;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPIMethod;

/**
 * runtime模型服务：用于初始化系统模型构造runtime服务
 */
public interface SysRuntimeModelService {
    /**
     * 初始化模型
     */
    void init();

    /**
     * 重载/刷新模型
     */
    void reload();

    /**
     * 获取系统运行时对象
     *
     * @return
     */
    ISystemRuntime getSystemRuntime();

    /**
     * 获取系统适配器对象
     *
     * @return
     */
    static SysRuntimeAdapterService getSysRuntimeAdapterService() {
        return SpringContextHolder.getBean(SysRuntimeAdapterService.class);
    }

    /**
     * 获取实体辅助工具对象类
     * @return
     */
    static DataEntityUtil getDataEntityUtil() {
        return SpringContextHolder.getBean(DataEntityUtil.class);
    }

    /**
     * 获取实体运行时对象
     * @param entityName
     * @return
     */
    IDataEntityRuntime getDataEntityRuntime(String entityName, boolean bTryMode);

    /**
     * 获取实体运行时对象
     * @param cls 实体类对象
     * @return
     */
    IDataEntityRuntime getDataEntityRuntime(Class cls, boolean bTryMode);

    /**
     * 获取实体服务对象api运行时对象
     * @param entityName
     * @param bTryMode
     * @return
     */
    IDEServiceAPIRuntime getDEServiceAPIRuntime(ISysServiceAPIRuntime iSysServiceAPIRuntime, String entityName, boolean bTryMode);

    /**
     * 获取实体服务方法对象
     * @param iDEServiceAPIRuntime
     * @param actionName
     * @param bTryMode
     * @return
     */
    IPSDEServiceAPIMethod getPSDEServiceAPIMethod(IDEServiceAPIRuntime iDEServiceAPIRuntime, String actionName, boolean bTryMode);

    /**
     * 获取实体行为对象
     * @param dataEntityRuntime
     * @param actionName
     * @return
     */
    IPSDEAction getPSDEAction(IDataEntityRuntime dataEntityRuntime, String actionName, boolean bTryMode);



}
